home *** CD-ROM | disk | FTP | other *** search
- #ifndef __EXCEPTIONS__
- #define __EXCEPTIONS__
- /******************************************************************************\
- *
- * Apple Macintosh Developer Technical Support
- *
- * Exception-handling routines
- *
- * Program: ColorReset
- * File: Exception.h
- *
- * by: Forrest Tanaka
- *
- * Copyright © 1988-1991 Apple Computer, Inc.
- * All rights reserved.
- *
- \******************************************************************************/
-
-
- /******************************************************************************\
- * Types
- \******************************************************************************/
-
- typedef struct
- {
- long *exceptionType; /* Pointer to type of exception */
- short *exceptionCode; /* Pointer to code number of exception */
- unsigned long registers [12]; /* Holds saved values of registers, PC, SP */
- } ExceptionRec, *ExceptionPtr;
-
-
- /******************************************************************************\
- * ExceptionEntry - Define variables and location of exception-handling code
- *
- * This is an especially odd function in that when a routine calls this function,
- * it’s actually defining a location that the flow of control should jump to if
- * the Exception function is called later in the same routine. The calls should
- * be made like this:
- *
- * ExceptionRec environment;
- * long exceptionType;
- * long exceptionCode;
- * long errorType;
- * long errorCode;
- *
- * if (ExceptionEntry (&environment, &exceptionType, &exceptionCode))
- * {
- * Clean-up statements here;
- * Maybe present error message to user here;
- * return;
- * }
- * Normal statements here;
- * if (errorHasHappened)
- * Exception (&environment, errorType, errorCode);
- * Normal function statements here;
- *
- * The first time ExceptionEntry is called in a routine, it’s guaranteed to
- * return 0. The clean-up statements are skipped in this case. The flow of
- * control then proceeds to the normal program statements. If an error occurs
- * and Exception is called, then the flow of control suddenly jumps back to the
- * ExceptionEntry call. This time, -1 is returned, and exceptionType and
- * exceptionCode return whatever values were passed in the Exception call. At
- * this time, the routine should clean up anything it allocated, possibly present
- * an error message to the user, then return to the calling routine.
- \******************************************************************************/
-
- extern short ExceptionEntry(ExceptionPtr environment,
- long *exceptionType,
- long *exceptionCode);
-
-
- /******************************************************************************\
- * Exception - Signal that an exception has occured
- *
- * When an error occurs, Exception is called to pass control to the set of
- * statements that execute when ExceptionEntry returns true. The environment
- * parameter specifies the same record that was passed to ExceptionEntry. If
- * it specifies a different record, then unpredictable things can happen. The
- * exceptionType and exceptionCode parameters specify values to be returned in
- * the corresponding parameters to ExceptionEntry. In this application they’re
- * normally used to pass the type of error and the code of the specific error
- * that occured.
- \******************************************************************************/
-
- extern void Exception(ExceptionPtr environment,
- long exceptionType,
- long exceptionCode);
-
-
- #endif
-